//
//  cashViewController.m
//  lmq
//
//  Created by 马田成 on 2017/3/22.
//  Copyright © 2017年 yuanxin. All rights reserved.
//

#import "cashViewController.h"
#import "EditMyBankCardViewController.h"

@interface cashViewController ()
{

    NSString *balanceID;
}

@property (weak, nonatomic) IBOutlet UILabel *balanceMoney;
@property (weak, nonatomic) IBOutlet UILabel *feeLabel;
@property (weak, nonatomic) IBOutlet UIButton *balanceLabel;
@property (weak, nonatomic) IBOutlet UITextField *moneyTextField;

@end

@implementation cashViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"余额提现";
    [self creationDate];
    
    // Do any additional setup after loading the view from its nib.
}
//银行卡详情
- (IBAction)addBankCard:(UIButton *)sender {
    
        
    EditMyBankCardViewController *vc = [[EditMyBankCardViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    
}

- (IBAction)withdrawal:(UIButton *)sender {
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];

    [productParams setValue:balanceID forKey:@"id"];
    [productParams setValue:self.moneyTextField forKey:@"money"];
    
    [productParams setValue:tokenStr forKey:@"token"];
    
    
    
    [[MNetworkHandler sharedInstance]conURL:Home_TIXBalance
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       NSDictionary *dict1=[returnData objectForKey:@"data"];
                                       ;
                                       NSLog(@"%@", dict1);
                                       

                                       
                                   }
                                   else {
                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];

    
}

- (void)creationDate{
    
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];

    [productParams setValue:tokenStr forKey:@"token"];


    
    [[MNetworkHandler sharedInstance]conURL:Home_TheBalanceOfTiX
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       NSDictionary *dict1=[returnData objectForKey:@"data"];
                                       ;
                                       NSLog(@"%@", dict1);
                                       
                                       [self.balanceLabel setTitle:[dict1 objectForKey:@"bank_name"] forState:UIControlStateNormal];
                                       NSString *str = @"手续费";
                                       self.feeLabel.text = [str stringByAppendingString:[dict1 objectForKey:@"fee"]];
                                       self.balanceMoney.text = [dict1 objectForKey:@"balance"];
                                       balanceID = [dict1 objectForKey:@"id"];
                                       

                                       
                                       

                                   }
                                   else {
                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];
    
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
